
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>16.函数进阶 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="../课余/编程exe.html" />
    
    
    <link rel="prev" href="15.变量进阶（理解）.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        <li class="header">笔记</li>
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../阶段一笔记/1.操作系统——特殊的软件.html">
            
                <a href="../阶段一笔记/1.操作系统——特殊的软件.html">
            
                    
                    1.操作系统——特殊的软件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../阶段一笔记/2.命令.html">
            
                <a href="../阶段一笔记/2.命令.html">
            
                    
                    2.命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../阶段一笔记/3.SSH客户端的简单使用.html">
            
                <a href="../阶段一笔记/3.SSH客户端的简单使用.html">
            
                    
                    3.SSH客户端的简单使用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../阶段一笔记/4.用户权限相关命令.html">
            
                <a href="../阶段一笔记/4.用户权限相关命令.html">
            
                    
                    4.用户权限相关命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../阶段一笔记/5.系统信息相关命令.html">
            
                <a href="../阶段一笔记/5.系统信息相关命令.html">
            
                    
                    5.系统信息相关命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../阶段一笔记/6.vi命令.html">
            
                <a href="../阶段一笔记/6.vi命令.html">
            
                    
                    6.vi命令
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">软件安装及其使用</li>
        
        
    

    
        
        <li class="header">pycharm</li>
        
        
    
        <li class="chapter " data-level="3.1" data-path="../阶段二笔记/pycharm安装及配置.html">
            
                <a href="../阶段二笔记/pycharm安装及配置.html">
            
                    
                    pycharm安装及配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="../阶段二笔记/pycharm使用.html">
            
                <a href="../阶段二笔记/pycharm使用.html">
            
                    
                    pycharm使用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="../阶段二笔记/pycharm激活问题.html">
            
                <a href="../阶段二笔记/pycharm激活问题.html">
            
                    
                    pycharm激活问题
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">电子书搭建</li>
        
        
    
        <li class="chapter " data-level="4.1" data-path="../阶段二笔记/gitbook安装.html">
            
                <a href="../阶段二笔记/gitbook安装.html">
            
                    
                    gitbook安装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.2" >
            
                <span>
            
                    
                    git
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.2.1" data-path="../阶段二笔记/git简要.html">
            
                <a href="../阶段二笔记/git简要.html">
            
                    
                    git简要
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.2.2" data-path="../阶段二笔记/git安装及使用.html">
            
                <a href="../阶段二笔记/git安装及使用.html">
            
                    
                    git安装及使用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.2.3" data-path="../阶段二笔记/git分支管理.html">
            
                <a href="../阶段二笔记/git分支管理.html">
            
                    
                    git分支管理
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="../阶段二笔记/github使用.html">
            
                <a href="../阶段二笔记/github使用.html">
            
                    
                    github使用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="../搭建/gitee远程仓库搭建.html">
            
                <a href="../搭建/gitee远程仓库搭建.html">
            
                    
                    gitee远程仓库搭建
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="../搭建/客户端与服务端的搭建.html">
            
                <a href="../搭建/客户端与服务端的搭建.html">
            
                    
                    客户端与服务端的搭建
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.6" >
            
                <span>
            
                    
                    问题
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.6.1" data-path="../搭建/gitbook build没有summary.html">
            
                <a href="../搭建/gitbook build没有summary.html">
            
                    
                    gitbook build没有summary
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.6.2" data-path="../问题/typora结合picgo实现上传图片到gitee.html">
            
                <a href="../问题/typora结合picgo实现上传图片到gitee.html">
            
                    
                    typora结合picgo实现上传图片到gitee
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="header">软件工具</li>
        
        
    
        <li class="chapter " data-level="5.1" data-path="../阶段二笔记/anaconda下载与使用.html">
            
                <a href="../阶段二笔记/anaconda下载与使用.html">
            
                    
                    anaconda下载与配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="../阶段二笔记/anaconda的使用.html">
            
                <a href="../阶段二笔记/anaconda的使用.html">
            
                    
                    anaconda的使用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.3" data-path="../阶段二笔记/python3.6.4下载与安装.html">
            
                <a href="../阶段二笔记/python3.6.4下载与安装.html">
            
                    
                    python3.6.4下载与安装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.4" data-path="../阶段二笔记/typora安装及配置.html">
            
                <a href="../阶段二笔记/typora安装及配置.html">
            
                    
                    typora安装及配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.5" data-path="../阶段二笔记/ubuntu  tool安装.html">
            
                <a href="../阶段二笔记/ubuntu  tool安装.html">
            
                    
                    ubuntu  tool安装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.6" data-path="../阶段二笔记/Jetbrains系列产品重置试用方法.html">
            
                <a href="../阶段二笔记/Jetbrains系列产品重置试用方法.html">
            
                    
                    Jetbrains系列产品重置试用方法
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">python学习</li>
        
        
    

    
        
        <li class="header">面对过程</li>
        
        
    
        <li class="chapter " data-level="7.1" data-path="0.python学习.html">
            
                <a href="0.python学习.html">
            
                    
                    0.python学习
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.2" data-path="1.python简介.html">
            
                <a href="1.python简介.html">
            
                    
                    1.python简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.3" data-path="2.python程序no.1.html">
            
                <a href="2.python程序no.1.html">
            
                    
                    2.python程序
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.4" data-path="3.多文件项目的演练.html">
            
                <a href="3.多文件项目的演练.html">
            
                    
                    3.多文件项目的演练
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.5" data-path="4.程序注释.html">
            
                <a href="4.程序注释.html">
            
                    
                    4.程序注释
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.6" data-path="5.算数运算符.html">
            
                <a href="5.算数运算符.html">
            
                    
                    5.算数运算符
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.7" data-path="6.程序执行原理（科普）.html">
            
                <a href="6.程序执行原理（科普）.html">
            
                    
                    6.程序执行原理（科普）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.8" data-path="7.变量的基本使用.html">
            
                <a href="7.变量的基本使用.html">
            
                    
                    7.变量的基本使用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.9" data-path="8.变量的命名.html">
            
                <a href="8.变量的命名.html">
            
                    
                    8.变量的命名
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.10" data-path="9.判断（if）语句.html">
            
                <a href="9.判断（if）语句.html">
            
                    
                    9.判断（if）语句
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.11" data-path="10.运算符.html">
            
                <a href="10.运算符.html">
            
                    
                    10.运算符.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.12" data-path="11.循环.html">
            
                <a href="11.循环.html">
            
                    
                    11.循环.md
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.13" data-path="12.函数基础.html">
            
                <a href="12.函数基础.html">
            
                    
                    12.函数基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.14" data-path="13.高级变量类型.html">
            
                <a href="13.高级变量类型.html">
            
                    
                    13.函数基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.15" data-path="14.综合应用 —— 名片管理系统.html">
            
                <a href="14.综合应用 —— 名片管理系统.html">
            
                    
                    14.综合应用 —— 名片管理系统
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.16" data-path="15.变量进阶（理解）.html">
            
                <a href="15.变量进阶（理解）.html">
            
                    
                    15.变量进阶（理解）
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="7.17" data-path="16.函数进阶.html">
            
                <a href="16.函数进阶.html">
            
                    
                    16.函数进阶
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">面对对象</li>
        
        
    
        <li class="chapter " data-level="8.1" data-path="../课余/编程exe.html">
            
                <a href="../课余/编程exe.html">
            
                    
                    编程exe
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">问题</li>
        
        
    
        <li class="chapter " data-level="9.1" data-path="../问题/安装软件.html">
            
                <a href="../问题/安装软件.html">
            
                    
                    安装软件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.2" data-path="../问题/激活码网站.html">
            
                <a href="../问题/激活码网站.html">
            
                    
                    激活码网站
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.3" data-path="../问题/虚拟机.html">
            
                <a href="../问题/虚拟机.html">
            
                    
                    虚拟机
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.4" data-path="../问题/疑难杂症.html">
            
                <a href="../问题/疑难杂症.html">
            
                    
                    疑难杂症
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >16.函数进阶</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x51FD;&#x6570;&#x8FDB;&#x9636;">&#x51FD;&#x6570;&#x8FDB;&#x9636;</h1>
<h2 id="&#x76EE;&#x6807;">&#x76EE;&#x6807;</h2>
<ul>
<li>&#x51FD;&#x6570;&#x53C2;&#x6570;&#x548C;&#x8FD4;&#x56DE;&#x503C;&#x7684;&#x4F5C;&#x7528;</li>
<li>&#x51FD;&#x6570;&#x7684;&#x8FD4;&#x56DE;&#x503C; &#x8FDB;&#x9636;</li>
<li>&#x51FD;&#x6570;&#x7684;&#x53C2;&#x6570; &#x8FDB;&#x9636;</li>
<li>&#x9012;&#x5F52;&#x51FD;&#x6570;</li>
</ul>
<h2 id="01-&#x51FD;&#x6570;&#x53C2;&#x6570;&#x548C;&#x8FD4;&#x56DE;&#x503C;&#x7684;&#x4F5C;&#x7528;">01. &#x51FD;&#x6570;&#x53C2;&#x6570;&#x548C;&#x8FD4;&#x56DE;&#x503C;&#x7684;&#x4F5C;&#x7528;</h2>
<p>&#x51FD;&#x6570;&#x6839;&#x636E; <strong>&#x6709;&#x6CA1;&#x6709;&#x53C2;&#x6570;</strong> &#x4EE5;&#x53CA; <strong>&#x6709;&#x6CA1;&#x6709;&#x8FD4;&#x56DE;&#x503C;</strong>&#xFF0C;&#x53EF;&#x4EE5; <strong>&#x76F8;&#x4E92;&#x7EC4;&#x5408;</strong>&#xFF0C;&#x4E00;&#x5171;&#x6709; <strong>4 &#x79CD;</strong> &#x7EC4;&#x5408;&#x5F62;&#x5F0F;</p>
<ol>
<li>&#x65E0;&#x53C2;&#x6570;&#xFF0C;&#x65E0;&#x8FD4;&#x56DE;&#x503C;</li>
<li>&#x65E0;&#x53C2;&#x6570;&#xFF0C;&#x6709;&#x8FD4;&#x56DE;&#x503C;</li>
<li>&#x6709;&#x53C2;&#x6570;&#xFF0C;&#x65E0;&#x8FD4;&#x56DE;&#x503C;</li>
<li>&#x6709;&#x53C2;&#x6570;&#xFF0C;&#x6709;&#x8FD4;&#x56DE;&#x503C;</li>
</ol>
<p><img src="https://s2.loli.net/2022/01/11/VRvqFS4xZLK6byG.png" alt="001_&#x51FD;&#x6570;&#x53C2;&#x6570;&#x548C;&#x8FD4;&#x56DE;&#x503C;.png"></p>
<blockquote>
<p>&#x5B9A;&#x4E49;&#x51FD;&#x6570;&#x65F6;&#xFF0C;<strong>&#x662F;&#x5426;&#x63A5;&#x6536;&#x53C2;&#x6570;&#xFF0C;&#x6216;&#x8005;&#x662F;&#x5426;&#x8FD4;&#x56DE;&#x7ED3;&#x679C;</strong>&#xFF0C;&#x662F;&#x6839;&#x636E; <strong>&#x5B9E;&#x9645;&#x7684;&#x529F;&#x80FD;&#x9700;&#x6C42;</strong> &#x6765;&#x51B3;&#x5B9A;&#x7684;&#xFF01;</p>
</blockquote>
<ol>
<li>&#x5982;&#x679C;&#x51FD;&#x6570; <strong>&#x5185;&#x90E8;&#x5904;&#x7406;&#x7684;&#x6570;&#x636E;&#x4E0D;&#x786E;&#x5B9A;</strong>&#xFF0C;&#x5C31;&#x53EF;&#x4EE5;&#x5C06;&#x5916;&#x754C;&#x7684;&#x6570;&#x636E;&#x4EE5;&#x53C2;&#x6570;&#x4F20;&#x9012;&#x5230;&#x51FD;&#x6570;&#x5185;&#x90E8;</li>
<li>&#x5982;&#x679C;&#x5E0C;&#x671B;&#x4E00;&#x4E2A;&#x51FD;&#x6570; <strong>&#x6267;&#x884C;&#x5B8C;&#x6210;&#x540E;&#xFF0C;&#x5411;&#x5916;&#x754C;&#x6C47;&#x62A5;&#x6267;&#x884C;&#x7ED3;&#x679C;</strong>&#xFF0C;&#x5C31;&#x53EF;&#x4EE5;&#x589E;&#x52A0;&#x51FD;&#x6570;&#x7684;&#x8FD4;&#x56DE;&#x503C;</li>
</ol>
<h3 id="11-&#x65E0;&#x53C2;&#x6570;&#xFF0C;&#x65E0;&#x8FD4;&#x56DE;&#x503C;">1.1 &#x65E0;&#x53C2;&#x6570;&#xFF0C;&#x65E0;&#x8FD4;&#x56DE;&#x503C;</h3>
<p>&#x6B64;&#x7C7B;&#x51FD;&#x6570;&#xFF0C;&#x4E0D;&#x63A5;&#x6536;&#x53C2;&#x6570;&#xFF0C;&#x4E5F;&#x6CA1;&#x6709;&#x8FD4;&#x56DE;&#x503C;&#xFF0C;&#x5E94;&#x7528;&#x573A;&#x666F;&#x5982;&#x4E0B;&#xFF1A;</p>
<ol>
<li><strong>&#x53EA;&#x662F;&#x5355;&#x7EAF;&#x5730;&#x505A;&#x4E00;&#x4EF6;&#x4E8B;&#x60C5;</strong>&#xFF0C;&#x4F8B;&#x5982; <strong>&#x663E;&#x793A;&#x83DC;&#x5355;</strong></li>
<li>&#x5728;&#x51FD;&#x6570;&#x5185;&#x90E8; <strong>&#x9488;&#x5BF9;&#x5168;&#x5C40;&#x53D8;&#x91CF;&#x8FDB;&#x884C;&#x64CD;&#x4F5C;</strong>&#xFF0C;&#x4F8B;&#x5982;&#xFF1A;<strong>&#x65B0;&#x5EFA;&#x540D;&#x7247;</strong>&#xFF0C;&#x6700;&#x7EC8;&#x7ED3;&#x679C; <strong>&#x8BB0;&#x5F55;&#x5728;&#x5168;&#x5C40;&#x53D8;&#x91CF;</strong> &#x4E2D;</li>
</ol>
<blockquote>
<p>&#x6CE8;&#x610F;&#xFF1A;</p>
</blockquote>
<ul>
<li>&#x5982;&#x679C;&#x5168;&#x5C40;&#x53D8;&#x91CF;&#x7684;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x662F;&#x4E00;&#x4E2A; <strong>&#x53EF;&#x53D8;&#x7C7B;&#x578B;</strong>&#xFF0C;&#x5728;&#x51FD;&#x6570;&#x5185;&#x90E8;&#x53EF;&#x4EE5;&#x4F7F;&#x7528; <strong>&#x65B9;&#x6CD5;</strong> &#x4FEE;&#x6539;&#x5168;&#x5C40;&#x53D8;&#x91CF;&#x7684;&#x5185;&#x5BB9; &#x2014;&#x2014; <strong>&#x53D8;&#x91CF;&#x7684;&#x5F15;&#x7528;&#x4E0D;&#x4F1A;&#x6539;&#x53D8;</strong></li>
<li>&#x5728;&#x51FD;&#x6570;&#x5185;&#x90E8;&#xFF0C;<strong>&#x4F7F;&#x7528;&#x8D4B;&#x503C;&#x8BED;&#x53E5;</strong> &#x624D;&#x4F1A; <strong>&#x4FEE;&#x6539;&#x53D8;&#x91CF;&#x7684;&#x5F15;&#x7528;</strong></li>
</ul>
<h3 id="12-&#x65E0;&#x53C2;&#x6570;&#xFF0C;&#x6709;&#x8FD4;&#x56DE;&#x503C;">1.2 &#x65E0;&#x53C2;&#x6570;&#xFF0C;&#x6709;&#x8FD4;&#x56DE;&#x503C;</h3>
<p>&#x6B64;&#x7C7B;&#x51FD;&#x6570;&#xFF0C;&#x4E0D;&#x63A5;&#x6536;&#x53C2;&#x6570;&#xFF0C;&#x4F46;&#x662F;&#x6709;&#x8FD4;&#x56DE;&#x503C;&#xFF0C;&#x5E94;&#x7528;&#x573A;&#x666F;&#x5982;&#x4E0B;&#xFF1A;</p>
<ul>
<li>&#x91C7;&#x96C6;&#x6570;&#x636E;&#xFF0C;&#x4F8B;&#x5982; <strong>&#x6E29;&#x5EA6;&#x8BA1;</strong>&#xFF0C;&#x8FD4;&#x56DE;&#x7ED3;&#x679C;&#x5C31;&#x662F;&#x5F53;&#x524D;&#x7684;&#x6E29;&#x5EA6;&#xFF0C;&#x800C;&#x4E0D;&#x9700;&#x8981;&#x4F20;&#x9012;&#x4EFB;&#x4F55;&#x7684;&#x53C2;&#x6570;</li>
</ul>
<h3 id="13-&#x6709;&#x53C2;&#x6570;&#xFF0C;&#x65E0;&#x8FD4;&#x56DE;&#x503C;">1.3 &#x6709;&#x53C2;&#x6570;&#xFF0C;&#x65E0;&#x8FD4;&#x56DE;&#x503C;</h3>
<p>&#x6B64;&#x7C7B;&#x51FD;&#x6570;&#xFF0C;&#x63A5;&#x6536;&#x53C2;&#x6570;&#xFF0C;&#x6CA1;&#x6709;&#x8FD4;&#x56DE;&#x503C;&#xFF0C;&#x5E94;&#x7528;&#x573A;&#x666F;&#x5982;&#x4E0B;&#xFF1A;</p>
<ul>
<li>&#x51FD;&#x6570;&#x5185;&#x90E8;&#x7684;&#x4EE3;&#x7801;&#x4FDD;&#x6301;&#x4E0D;&#x53D8;&#xFF0C;&#x9488;&#x5BF9; <strong>&#x4E0D;&#x540C;&#x7684;&#x53C2;&#x6570; &#x5904;&#x7406; &#x4E0D;&#x540C;&#x7684;&#x6570;&#x636E;</strong></li>
<li>&#x4F8B;&#x5982; <strong>&#x540D;&#x7247;&#x7BA1;&#x7406;&#x7CFB;&#x7EDF;</strong> &#x9488;&#x5BF9; <strong>&#x627E;&#x5230;&#x7684;&#x540D;&#x7247;</strong> &#x505A; <strong>&#x4FEE;&#x6539;</strong>&#x3001;<strong>&#x5220;&#x9664;</strong> &#x64CD;&#x4F5C;</li>
</ul>
<h3 id="14-&#x6709;&#x53C2;&#x6570;&#xFF0C;&#x6709;&#x8FD4;&#x56DE;&#x503C;">1.4 &#x6709;&#x53C2;&#x6570;&#xFF0C;&#x6709;&#x8FD4;&#x56DE;&#x503C;</h3>
<p>&#x6B64;&#x7C7B;&#x51FD;&#x6570;&#xFF0C;&#x63A5;&#x6536;&#x53C2;&#x6570;&#xFF0C;&#x540C;&#x65F6;&#x6709;&#x8FD4;&#x56DE;&#x503C;&#xFF0C;&#x5E94;&#x7528;&#x573A;&#x666F;&#x5982;&#x4E0B;&#xFF1A;</p>
<ul>
<li>&#x51FD;&#x6570;&#x5185;&#x90E8;&#x7684;&#x4EE3;&#x7801;&#x4FDD;&#x6301;&#x4E0D;&#x53D8;&#xFF0C;&#x9488;&#x5BF9; <strong>&#x4E0D;&#x540C;&#x7684;&#x53C2;&#x6570; &#x5904;&#x7406; &#x4E0D;&#x540C;&#x7684;&#x6570;&#x636E;</strong>&#xFF0C;&#x5E76;&#x4E14; <strong>&#x8FD4;&#x56DE;&#x671F;&#x671B;&#x7684;&#x5904;&#x7406;&#x7ED3;&#x679C;</strong></li>
<li>&#x4F8B;&#x5982; <strong>&#x540D;&#x7247;&#x7BA1;&#x7406;&#x7CFB;&#x7EDF;</strong> &#x4F7F;&#x7528; <strong>&#x5B57;&#x5178;&#x9ED8;&#x8BA4;&#x503C;</strong> &#x548C; <strong>&#x63D0;&#x793A;&#x4FE1;&#x606F;</strong> &#x63D0;&#x793A;&#x7528;&#x6237;&#x8F93;&#x5165;&#x5185;&#x5BB9;<ul>
<li>&#x5982;&#x679C;&#x8F93;&#x5165;&#xFF0C;&#x8FD4;&#x56DE;&#x8F93;&#x5165;&#x5185;&#x5BB9;</li>
<li>&#x5982;&#x679C;&#x6CA1;&#x6709;&#x8F93;&#x5165;&#xFF0C;&#x8FD4;&#x56DE;&#x5B57;&#x5178;&#x9ED8;&#x8BA4;&#x503C;</li>
</ul>
</li>
</ul>
<h2 id="02-&#x51FD;&#x6570;&#x7684;&#x8FD4;&#x56DE;&#x503C;-&#x8FDB;&#x9636;">02. &#x51FD;&#x6570;&#x7684;&#x8FD4;&#x56DE;&#x503C; &#x8FDB;&#x9636;</h2>
<ul>
<li>&#x5728;&#x7A0B;&#x5E8F;&#x5F00;&#x53D1;&#x4E2D;&#xFF0C;&#x6709;&#x65F6;&#x5019;&#xFF0C;&#x4F1A;&#x5E0C;&#x671B; <strong>&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#x6267;&#x884C;&#x7ED3;&#x675F;&#x540E;&#xFF0C;&#x544A;&#x8BC9;&#x8C03;&#x7528;&#x8005;&#x4E00;&#x4E2A;&#x7ED3;&#x679C;</strong>&#xFF0C;&#x4EE5;&#x4FBF;&#x8C03;&#x7528;&#x8005;&#x9488;&#x5BF9;&#x5177;&#x4F53;&#x7684;&#x7ED3;&#x679C;&#x505A;&#x540E;&#x7EED;&#x7684;&#x5904;&#x7406;</li>
<li><strong>&#x8FD4;&#x56DE;&#x503C;</strong> &#x662F;&#x51FD;&#x6570; <strong>&#x5B8C;&#x6210;&#x5DE5;&#x4F5C;</strong>&#x540E;&#xFF0C;<strong>&#x6700;&#x540E;</strong> &#x7ED9;&#x8C03;&#x7528;&#x8005;&#x7684; <strong>&#x4E00;&#x4E2A;&#x7ED3;&#x679C;</strong></li>
<li>&#x5728;&#x51FD;&#x6570;&#x4E2D;&#x4F7F;&#x7528; <code>return</code> &#x5173;&#x952E;&#x5B57;&#x53EF;&#x4EE5;&#x8FD4;&#x56DE;&#x7ED3;&#x679C;</li>
<li>&#x8C03;&#x7528;&#x51FD;&#x6570;&#x4E00;&#x65B9;&#xFF0C;&#x53EF;&#x4EE5; <strong>&#x4F7F;&#x7528;&#x53D8;&#x91CF;</strong> &#x6765; <strong>&#x63A5;&#x6536;</strong> &#x51FD;&#x6570;&#x7684;&#x8FD4;&#x56DE;&#x7ED3;&#x679C;</li>
</ul>
<blockquote>
<p>&#x95EE;&#x9898;&#xFF1A;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#x6267;&#x884C;&#x540E;&#x80FD;&#x5426;&#x8FD4;&#x56DE;&#x591A;&#x4E2A;&#x7ED3;&#x679C;&#xFF1F;</p>
</blockquote>
<h3 id="&#x793A;&#x4F8B;-&#x2014;&#x2014;-&#x6E29;&#x5EA6;&#x548C;&#x6E7F;&#x5EA6;&#x6D4B;&#x91CF;">&#x793A;&#x4F8B; &#x2014;&#x2014; &#x6E29;&#x5EA6;&#x548C;&#x6E7F;&#x5EA6;&#x6D4B;&#x91CF;</h3>
<ul>
<li>&#x5047;&#x8BBE;&#x8981;&#x5F00;&#x53D1;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#x80FD;&#x591F;&#x540C;&#x65F6;&#x8FD4;&#x56DE;&#x5F53;&#x524D;&#x7684;&#x6E29;&#x5EA6;&#x548C;&#x6E7F;&#x5EA6;</li>
<li><strong>&#x5148;&#x5B8C;&#x6210;&#x8FD4;&#x56DE;&#x6E29;&#x5EA6;</strong>&#x7684;&#x529F;&#x80FD;&#x5982;&#x4E0B;&#xFF1A;</li>
</ul>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">measure</span><span class="hljs-params">()</span>:</span>
    <span class="hljs-string">&quot;&quot;&quot;&#x8FD4;&#x56DE;&#x5F53;&#x524D;&#x7684;&#x6E29;&#x5EA6;&quot;&quot;&quot;</span>

    print(<span class="hljs-string">&quot;&#x5F00;&#x59CB;&#x6D4B;&#x91CF;...&quot;</span>)
    temp = <span class="hljs-number">39</span>
    print(<span class="hljs-string">&quot;&#x6D4B;&#x91CF;&#x7ED3;&#x675F;...&quot;</span>)

    <span class="hljs-keyword">return</span> temp

result = measure()
print(result)
</code></pre>
<ul>
<li>&#x5728;&#x5229;&#x7528; <strong>&#x5143;&#x7EC4;</strong> &#x5728;&#x8FD4;&#x56DE;&#x6E29;&#x5EA6;&#x7684;&#x540C;&#x65F6;&#xFF0C;&#x4E5F;&#x80FD;&#x591F;&#x8FD4;&#x56DE; <strong>&#x6E7F;&#x5EA6;</strong></li>
<li>&#x6539;&#x9020;&#x5982;&#x4E0B;&#xFF1A;</li>
</ul>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">measure</span><span class="hljs-params">()</span>:</span>
    <span class="hljs-string">&quot;&quot;&quot;&#x8FD4;&#x56DE;&#x5F53;&#x524D;&#x7684;&#x6E29;&#x5EA6;&quot;&quot;&quot;</span>

    print(<span class="hljs-string">&quot;&#x5F00;&#x59CB;&#x6D4B;&#x91CF;...&quot;</span>)
    temp = <span class="hljs-number">39</span>
    wetness = <span class="hljs-number">10</span>
    print(<span class="hljs-string">&quot;&#x6D4B;&#x91CF;&#x7ED3;&#x675F;...&quot;</span>)

    <span class="hljs-keyword">return</span> (temp, wetness)
</code></pre>
<blockquote>
<p>&#x63D0;&#x793A;&#xFF1A;&#x5982;&#x679C;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#x8FD4;&#x56DE;&#x7684;&#x662F;&#x5143;&#x7EC4;&#xFF0C;&#x62EC;&#x53F7;&#x53EF;&#x4EE5;&#x7701;&#x7565;</p>
</blockquote>
<p><strong>&#x6280;&#x5DE7;</strong> </p>
<ul>
<li>&#x5728; <code>Python</code> &#x4E2D;&#xFF0C;&#x53EF;&#x4EE5; <strong>&#x5C06;&#x4E00;&#x4E2A;&#x5143;&#x7EC4;</strong> &#x4F7F;&#x7528; <strong>&#x8D4B;&#x503C;&#x8BED;&#x53E5;</strong> &#x540C;&#x65F6;&#x8D4B;&#x503C;&#x7ED9; <strong>&#x591A;&#x4E2A;&#x53D8;&#x91CF;</strong></li>
<li>&#x6CE8;&#x610F;&#xFF1A;&#x53D8;&#x91CF;&#x7684;&#x6570;&#x91CF;&#x9700;&#x8981;&#x548C;&#x5143;&#x7EC4;&#x4E2D;&#x7684;&#x5143;&#x7D20;&#x6570;&#x91CF;&#x4FDD;&#x6301;&#x4E00;&#x81F4;</li>
</ul>
<pre><code class="lang-python">result = temp, wetness = measure()
</code></pre>
<h3 id="&#x9762;&#x8BD5;&#x9898;-&#x2014;&#x2014;-&#x4EA4;&#x6362;&#x4E24;&#x4E2A;&#x6570;&#x5B57;">&#x9762;&#x8BD5;&#x9898; &#x2014;&#x2014; &#x4EA4;&#x6362;&#x4E24;&#x4E2A;&#x6570;&#x5B57;</h3>
<p><strong>&#x9898;&#x76EE;&#x8981;&#x6C42;</strong></p>
<ol>
<li>&#x6709;&#x4E24;&#x4E2A;&#x6574;&#x6570;&#x53D8;&#x91CF; <code>a = 6</code>, <code>b = 100</code></li>
<li>&#x4E0D;&#x4F7F;&#x7528;&#x5176;&#x4ED6;&#x53D8;&#x91CF;&#xFF0C;<strong>&#x4EA4;&#x6362;&#x4E24;&#x4E2A;&#x53D8;&#x91CF;&#x7684;&#x503C;</strong></li>
</ol>
<h4 id="&#x89E3;&#x6CD5;-1-&#x2014;&#x2014;-&#x4F7F;&#x7528;&#x5176;&#x4ED6;&#x53D8;&#x91CF;">&#x89E3;&#x6CD5; 1 &#x2014;&#x2014; &#x4F7F;&#x7528;&#x5176;&#x4ED6;&#x53D8;&#x91CF;</h4>
<pre><code class="lang-python"><span class="hljs-comment"># &#x89E3;&#x6CD5; 1 - &#x4F7F;&#x7528;&#x4E34;&#x65F6;&#x53D8;&#x91CF;</span>
c = b
b = a
a = c
</code></pre>
<h4 id="&#x89E3;&#x6CD5;-2-&#x2014;&#x2014;-&#x4E0D;&#x4F7F;&#x7528;&#x4E34;&#x65F6;&#x53D8;&#x91CF;">&#x89E3;&#x6CD5; 2 &#x2014;&#x2014; &#x4E0D;&#x4F7F;&#x7528;&#x4E34;&#x65F6;&#x53D8;&#x91CF;</h4>
<pre><code class="lang-python"><span class="hljs-comment"># &#x89E3;&#x6CD5; 2 - &#x4E0D;&#x4F7F;&#x7528;&#x4E34;&#x65F6;&#x53D8;&#x91CF;</span>
a = a + b
b = a - b
a = a - b
</code></pre>
<h4 id="&#x89E3;&#x6CD5;-3-&#x2014;&#x2014;-python-&#x4E13;&#x6709;&#xFF0C;&#x5229;&#x7528;&#x5143;&#x7EC4;">&#x89E3;&#x6CD5; 3 &#x2014;&#x2014; Python &#x4E13;&#x6709;&#xFF0C;&#x5229;&#x7528;&#x5143;&#x7EC4;</h4>
<pre><code class="lang-python">a, b = b, a
</code></pre>
<h2 id="03-&#x51FD;&#x6570;&#x7684;&#x53C2;&#x6570;-&#x8FDB;&#x9636;">03. &#x51FD;&#x6570;&#x7684;&#x53C2;&#x6570; &#x8FDB;&#x9636;</h2>
<h3 id="31-&#x4E0D;&#x53EF;&#x53D8;&#x548C;&#x53EF;&#x53D8;&#x7684;&#x53C2;&#x6570;">3.1. &#x4E0D;&#x53EF;&#x53D8;&#x548C;&#x53EF;&#x53D8;&#x7684;&#x53C2;&#x6570;</h3>
<blockquote>
<p>&#x95EE;&#x9898; 1&#xFF1A;&#x5728;&#x51FD;&#x6570;&#x5185;&#x90E8;&#xFF0C;&#x9488;&#x5BF9;&#x53C2;&#x6570;&#x4F7F;&#x7528; <strong>&#x8D4B;&#x503C;&#x8BED;&#x53E5;</strong>&#xFF0C;&#x4F1A;&#x4E0D;&#x4F1A;&#x5F71;&#x54CD;&#x8C03;&#x7528;&#x51FD;&#x6570;&#x65F6;&#x4F20;&#x9012;&#x7684; <strong>&#x5B9E;&#x53C2;&#x53D8;&#x91CF;</strong>&#xFF1F; &#x2014;&#x2014; &#x4E0D;&#x4F1A;&#xFF01;</p>
</blockquote>
<ul>
<li>&#x65E0;&#x8BBA;&#x4F20;&#x9012;&#x7684;&#x53C2;&#x6570;&#x662F; <strong>&#x53EF;&#x53D8;</strong> &#x8FD8;&#x662F; <strong>&#x4E0D;&#x53EF;&#x53D8;</strong> <ul>
<li>&#x53EA;&#x8981; <strong>&#x9488;&#x5BF9;&#x53C2;&#x6570;</strong> &#x4F7F;&#x7528; <strong>&#x8D4B;&#x503C;&#x8BED;&#x53E5;</strong>&#xFF0C;&#x4F1A;&#x5728; <strong>&#x51FD;&#x6570;&#x5185;&#x90E8;</strong> &#x4FEE;&#x6539; <strong>&#x5C40;&#x90E8;&#x53D8;&#x91CF;&#x7684;&#x5F15;&#x7528;</strong>&#xFF0C;<strong>&#x4E0D;&#x4F1A;&#x5F71;&#x54CD;&#x5230; &#x5916;&#x90E8;&#x53D8;&#x91CF;&#x7684;&#x5F15;&#x7528;</strong></li>
</ul>
</li>
</ul>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">demo</span><span class="hljs-params">(num, num_list)</span>:</span>

    print(<span class="hljs-string">&quot;&#x51FD;&#x6570;&#x5185;&#x90E8;&quot;</span>)

    <span class="hljs-comment"># &#x8D4B;&#x503C;&#x8BED;&#x53E5;</span>
    num = <span class="hljs-number">200</span>
    num_list = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>]

    print(num)
    print(num_list)

    print(<span class="hljs-string">&quot;&#x51FD;&#x6570;&#x4EE3;&#x7801;&#x5B8C;&#x6210;&quot;</span>)


gl_num = <span class="hljs-number">99</span>
gl_list = [<span class="hljs-number">4</span>, <span class="hljs-number">5</span>, <span class="hljs-number">6</span>]
demo(gl_num, gl_list)
print(gl_num)
print(gl_list)
</code></pre>
<p><img src="https://s2.loli.net/2022/03/14/r1LDhb3GjTcXgUa.png" alt="image-20220314172220533">    <img src="https://s2.loli.net/2022/03/14/M5yAzrgcjS8Resb.png" alt=""></p>
<blockquote>
<p>&#x95EE;&#x9898; 2&#xFF1A;&#x5982;&#x679C;&#x4F20;&#x9012;&#x7684;&#x53C2;&#x6570;&#x662F; <strong>&#x53EF;&#x53D8;&#x7C7B;&#x578B;</strong>&#xFF0C;&#x5728;&#x51FD;&#x6570;&#x5185;&#x90E8;&#xFF0C;&#x4F7F;&#x7528; <strong>&#x65B9;&#x6CD5;</strong> &#x4FEE;&#x6539;&#x4E86;&#x6570;&#x636E;&#x7684;&#x5185;&#x5BB9;&#xFF0C;<strong>&#x540C;&#x6837;&#x4F1A;&#x5F71;&#x54CD;&#x5230;&#x5916;&#x90E8;&#x7684;&#x6570;&#x636E;</strong></p>
</blockquote>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">mutable</span><span class="hljs-params">(num_list)</span>:</span>

    <span class="hljs-comment"># num_list = [1, 2, 3]</span>
    num_list.extend([<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>])

    print(num_list)

gl_list = [<span class="hljs-number">6</span>, <span class="hljs-number">7</span>, <span class="hljs-number">8</span>]
mutable(gl_list)
print(gl_list)
</code></pre>
<p>&#x200B;    <img src="https://s2.loli.net/2022/03/14/jWByehPCXJbNlEn.png" alt="image-20220314154025107"></p>
<h4 id="&#x9762;&#x8BD5;&#x9898;-&#x2014;&#x2014;-">&#x9762;&#x8BD5;&#x9898; &#x2014;&#x2014; <code>+=</code></h4>
<ul>
<li>&#x5728; <code>python</code> &#x4E2D;&#xFF0C;&#x5217;&#x8868;&#x53D8;&#x91CF;&#x8C03;&#x7528; <code>+=</code> &#x672C;&#x8D28;&#x4E0A;&#x662F;&#x5728;&#x6267;&#x884C;&#x5217;&#x8868;&#x53D8;&#x91CF;&#x7684; <code>extend</code> &#x65B9;&#x6CD5;&#xFF0C;<strong>&#x4E0D;&#x4F1A;&#x4FEE;&#x6539;&#x53D8;&#x91CF;&#x7684;&#x5F15;&#x7528;,&#x4F1A;&#x4FEE;&#x6539;&#x5916;&#x90E8;&#x6570;&#x636E;</strong><ul>
<li><code>.extend()</code> &#x53EF;&#x4EE5;&#x628A;&#x5176;&#x4ED6;&#x5217;&#x8868;&#x4E2D;&#x7684;&#x5B8C;&#x6574;&#x5185;&#x5BB9;&#xFF0C;&#x8FFD;&#x52A0;&#x5230;&#x5F53;&#x524D;&#x5217;&#x8868;&#x7684;&#x672B;&#x5C3E;</li>
</ul>
</li>
</ul>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">demo</span><span class="hljs-params">(num, num_list)</span>:</span>

    print(<span class="hljs-string">&quot;&#x51FD;&#x6570;&#x5185;&#x90E8;&#x4EE3;&#x7801;&quot;</span>)

    <span class="hljs-comment"># num = num + num</span>
    num += num
    <span class="hljs-comment"># num_list.extend(num_list) &#x7531;&#x4E8E;&#x662F;&#x8C03;&#x7528;&#x65B9;&#x6CD5;&#xFF0C;&#x6240;&#x4EE5;&#x4E0D;&#x4F1A;&#x4FEE;&#x6539;&#x53D8;&#x91CF;&#x7684;&#x5F15;&#x7528;</span>
    <span class="hljs-comment"># &#x51FD;&#x6570;&#x6267;&#x884C;&#x7ED3;&#x675F;&#x540E;&#xFF0C;&#x5916;&#x90E8;&#x6570;&#x636E;&#x540C;&#x6837;&#x4F1A;&#x53D1;&#x751F;&#x53D8;&#x5316;</span>
    num_list += num_list

    print(num)
    print(num_list)
    print(<span class="hljs-string">&quot;&#x51FD;&#x6570;&#x4EE3;&#x7801;&#x5B8C;&#x6210;&quot;</span>)


gl_num = <span class="hljs-number">9</span>
gl_list = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>]
demo(gl_num, gl_list)
print(gl_num)
print(gl_list)
</code></pre>
<h3 id="32-&#x7F3A;&#x7701;&#x53C2;&#x6570;">3.2 &#x7F3A;&#x7701;&#x53C2;&#x6570;</h3>
<ul>
<li>&#x5B9A;&#x4E49;&#x51FD;&#x6570;&#x65F6;&#xFF0C;&#x53EF;&#x4EE5;&#x7ED9; <strong>&#x67D0;&#x4E2A;&#x53C2;&#x6570;</strong> &#x6307;&#x5B9A;&#x4E00;&#x4E2A;<strong>&#x9ED8;&#x8BA4;&#x503C;</strong>&#xFF0C;&#x5177;&#x6709;&#x9ED8;&#x8BA4;&#x503C;&#x7684;&#x53C2;&#x6570;&#x5C31;&#x53EB;&#x505A; <strong>&#x7F3A;&#x7701;&#x53C2;&#x6570;</strong></li>
<li>&#x8C03;&#x7528;&#x51FD;&#x6570;&#x65F6;&#xFF0C;&#x5982;&#x679C;&#x6CA1;&#x6709;&#x4F20;&#x5165; <strong>&#x7F3A;&#x7701;&#x53C2;&#x6570;</strong> &#x7684;&#x503C;&#xFF0C;&#x5219;&#x5728;&#x51FD;&#x6570;&#x5185;&#x90E8;&#x4F7F;&#x7528;&#x5B9A;&#x4E49;&#x51FD;&#x6570;&#x65F6;&#x6307;&#x5B9A;&#x7684; <strong>&#x53C2;&#x6570;&#x9ED8;&#x8BA4;&#x503C;</strong></li>
<li>&#x51FD;&#x6570;&#x7684;&#x7F3A;&#x7701;&#x53C2;&#x6570;&#xFF0C;<strong>&#x5C06;&#x5E38;&#x89C1;&#x7684;&#x503C;&#x8BBE;&#x7F6E;&#x4E3A;&#x53C2;&#x6570;&#x7684;&#x7F3A;&#x7701;&#x503C;</strong>&#xFF0C;&#x4ECE;&#x800C; <strong>&#x7B80;&#x5316;&#x51FD;&#x6570;&#x7684;&#x8C03;&#x7528;</strong></li>
<li>&#x4F8B;&#x5982;&#xFF1A;&#x5BF9;&#x5217;&#x8868;&#x6392;&#x5E8F;&#x7684;&#x65B9;&#x6CD5;</li>
</ul>
<pre><code class="lang-python">gl_num_list = [<span class="hljs-number">6</span>, <span class="hljs-number">3</span>, <span class="hljs-number">9</span>]

<span class="hljs-comment"># &#x9ED8;&#x8BA4;&#x5C31;&#x662F;&#x5347;&#x5E8F;&#x6392;&#x5E8F;&#xFF0C;&#x56E0;&#x4E3A;&#x8FD9;&#x79CD;&#x5E94;&#x7528;&#x9700;&#x6C42;&#x66F4;&#x591A;</span>
gl_num_list.sort()
print(gl_num_list)

<span class="hljs-comment"># &#x53EA;&#x6709;&#x5F53;&#x9700;&#x8981;&#x964D;&#x5E8F;&#x6392;&#x5E8F;&#x65F6;&#xFF0C;&#x624D;&#x9700;&#x8981;&#x4F20;&#x9012; `reverse` &#x53C2;&#x6570;</span>
gl_num_list.sort(reverse=<span class="hljs-keyword">True</span>)
print(gl_num_list)
</code></pre>
<h4 id="&#x6307;&#x5B9A;&#x51FD;&#x6570;&#x7684;&#x7F3A;&#x7701;&#x53C2;&#x6570;">&#x6307;&#x5B9A;&#x51FD;&#x6570;&#x7684;&#x7F3A;&#x7701;&#x53C2;&#x6570;</h4>
<ul>
<li><p>&#x5728;&#x53C2;&#x6570;&#x540E;&#x4F7F;&#x7528;&#x8D4B;&#x503C;&#x8BED;&#x53E5;&#xFF0C;&#x53EF;&#x4EE5;&#x6307;&#x5B9A;&#x53C2;&#x6570;&#x7684;&#x7F3A;&#x7701;&#x503C;</p>
<p><img src="https://s2.loli.net/2022/03/14/M2OEsbIkDYxquAl.png" alt="image-20220314180447873"></p>
</li>
</ul>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">print_info</span><span class="hljs-params">(name, gender=True)</span>:</span>

    gender_text = <span class="hljs-string">&quot;&#x7537;&#x751F;&quot;</span>
    <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> gender:
        gender_text = <span class="hljs-string">&quot;&#x5973;&#x751F;&quot;</span>

    print(<span class="hljs-string">&quot;%s &#x662F; %s&quot;</span> % (name, gender_text))
</code></pre>
<p><strong>&#x63D0;&#x793A;</strong></p>
<ol>
<li>&#x7F3A;&#x7701;&#x53C2;&#x6570;&#xFF0C;&#x9700;&#x8981;&#x4F7F;&#x7528; <strong>&#x6700;&#x5E38;&#x89C1;&#x7684;&#x503C;</strong> &#x4F5C;&#x4E3A;&#x9ED8;&#x8BA4;&#x503C;&#xFF01;</li>
<li>&#x5982;&#x679C;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x7684;&#x503C; <strong>&#x4E0D;&#x80FD;&#x786E;&#x5B9A;</strong>&#xFF0C;&#x5219;&#x4E0D;&#x5E94;&#x8BE5;&#x8BBE;&#x7F6E;&#x9ED8;&#x8BA4;&#x503C;&#xFF0C;&#x5177;&#x4F53;&#x7684;&#x6570;&#x503C;&#x5728;&#x8C03;&#x7528;&#x51FD;&#x6570;&#x65F6;&#xFF0C;&#x7531;&#x5916;&#x754C;&#x4F20;&#x9012;&#xFF01;</li>
</ol>
<h4 id="&#x7F3A;&#x7701;&#x53C2;&#x6570;&#x7684;&#x6CE8;&#x610F;&#x4E8B;&#x9879;">&#x7F3A;&#x7701;&#x53C2;&#x6570;&#x7684;&#x6CE8;&#x610F;&#x4E8B;&#x9879;</h4>
<h5 id="1-&#x7F3A;&#x7701;&#x53C2;&#x6570;&#x7684;&#x5B9A;&#x4E49;&#x4F4D;&#x7F6E;">1) &#x7F3A;&#x7701;&#x53C2;&#x6570;&#x7684;&#x5B9A;&#x4E49;&#x4F4D;&#x7F6E;</h5>
<ul>
<li><strong>&#x5FC5;&#x987B;&#x4FDD;&#x8BC1;</strong> <strong>&#x5E26;&#x6709;&#x9ED8;&#x8BA4;&#x503C;&#x7684;&#x7F3A;&#x7701;&#x53C2;&#x6570;</strong> <strong>&#x5728;&#x53C2;&#x6570;&#x5217;&#x8868;&#x672B;&#x5C3E;</strong></li>
<li>&#x6240;&#x4EE5;&#xFF0C;&#x4EE5;&#x4E0B;&#x5B9A;&#x4E49;&#x662F;&#x9519;&#x8BEF;&#x7684;&#xFF01;</li>
</ul>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">print_info</span><span class="hljs-params">(name, gender=True, title)</span>:</span>
</code></pre>
<ul>
<li>&#x6B63;&#x786E;&#xFF1A;</li>
</ul>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">print_info</span><span class="hljs-params">(name, title&#xFF0C;gender=True)</span>:</span>
</code></pre>
<h5 id="2-&#x8C03;&#x7528;&#x5E26;&#x6709;&#x591A;&#x4E2A;&#x7F3A;&#x7701;&#x53C2;&#x6570;&#x7684;&#x51FD;&#x6570;">2) &#x8C03;&#x7528;&#x5E26;&#x6709;&#x591A;&#x4E2A;&#x7F3A;&#x7701;&#x53C2;&#x6570;&#x7684;&#x51FD;&#x6570;</h5>
<ul>
<li>&#x5728; <strong>&#x8C03;&#x7528;&#x51FD;&#x6570;&#x65F6;</strong>&#xFF0C;&#x5982;&#x679C;&#x6709; <strong>&#x591A;&#x4E2A;&#x7F3A;&#x7701;&#x53C2;&#x6570;</strong>&#xFF0C;<strong>&#x9700;&#x8981;&#x6307;&#x5B9A;&#x53C2;&#x6570;&#x540D;</strong>&#xFF0C;&#x8FD9;&#x6837;&#x89E3;&#x91CA;&#x5668;&#x624D;&#x80FD;&#x591F;&#x77E5;&#x9053;&#x53C2;&#x6570;&#x7684;&#x5BF9;&#x5E94;&#x5173;&#x7CFB;&#xFF01;</li>
</ul>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">print_info</span><span class="hljs-params">(name, title=<span class="hljs-string">&quot;&quot;</span>, gender=True)</span>:</span>
    <span class="hljs-string">&quot;&quot;&quot;

    :param title: &#x804C;&#x4F4D;
    :param name: &#x73ED;&#x4E0A;&#x540C;&#x5B66;&#x7684;&#x59D3;&#x540D;
    :param gender: True &#x7537;&#x751F; False &#x5973;&#x751F;
    &quot;&quot;&quot;</span>

    gender_text = <span class="hljs-string">&quot;&#x7537;&#x751F;&quot;</span>

    <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> gender:
        gender_text = <span class="hljs-string">&quot;&#x5973;&#x751F;&quot;</span>

    print(<span class="hljs-string">&quot;%s%s &#x662F; %s&quot;</span> % (title, name, gender_text))


<span class="hljs-comment"># &#x63D0;&#x793A;&#xFF1A;&#x5728;&#x6307;&#x5B9A;&#x7F3A;&#x7701;&#x53C2;&#x6570;&#x7684;&#x9ED8;&#x8BA4;&#x503C;&#x65F6;&#xFF0C;&#x5E94;&#x8BE5;&#x4F7F;&#x7528;&#x6700;&#x5E38;&#x89C1;&#x7684;&#x503C;&#x4F5C;&#x4E3A;&#x9ED8;&#x8BA4;&#x503C;&#xFF01;</span>
print_info(<span class="hljs-string">&quot;&#x5C0F;&#x660E;&quot;</span>)
print_info(<span class="hljs-string">&quot;&#x8001;&#x738B;&quot;</span>, title=<span class="hljs-string">&quot;&#x73ED;&#x957F;&quot;</span>)
print_info(<span class="hljs-string">&quot;&#x5C0F;&#x7F8E;&quot;</span>, gender=<span class="hljs-keyword">False</span>)
</code></pre>
<h3 id="33-&#x591A;&#x503C;&#x53C2;&#x6570;&#xFF08;&#x77E5;&#x9053;&#xFF09;">3.3 &#x591A;&#x503C;&#x53C2;&#x6570;&#xFF08;&#x77E5;&#x9053;&#xFF09;</h3>
<h4 id="&#x5B9A;&#x4E49;&#x652F;&#x6301;&#x591A;&#x503C;&#x53C2;&#x6570;&#x7684;&#x51FD;&#x6570;">&#x5B9A;&#x4E49;&#x652F;&#x6301;&#x591A;&#x503C;&#x53C2;&#x6570;&#x7684;&#x51FD;&#x6570;</h4>
<ul>
<li>&#x6709;&#x65F6;&#x53EF;&#x80FD;&#x9700;&#x8981; <strong>&#x4E00;&#x4E2A;&#x51FD;&#x6570;</strong> &#x80FD;&#x591F;&#x5904;&#x7406;&#x7684;&#x53C2;&#x6570; <strong>&#x4E2A;&#x6570;</strong> &#x662F;&#x4E0D;&#x786E;&#x5B9A;&#x7684;&#xFF0C;&#x8FD9;&#x4E2A;&#x65F6;&#x5019;&#xFF0C;&#x5C31;&#x53EF;&#x4EE5;&#x4F7F;&#x7528; <strong>&#x591A;&#x503C;&#x53C2;&#x6570;</strong></li>
<li><code>python</code> &#x4E2D;&#x6709; <strong>&#x4E24;&#x79CD;</strong> &#x591A;&#x503C;&#x53C2;&#x6570;&#xFF1A;<ul>
<li>&#x53C2;&#x6570;&#x540D;&#x524D;&#x589E;&#x52A0; <strong>&#x4E00;&#x4E2A;</strong> <code>*</code> &#x53EF;&#x4EE5;&#x63A5;&#x6536; <strong>&#x5143;&#x7EC4;</strong></li>
<li>&#x53C2;&#x6570;&#x540D;&#x524D;&#x589E;&#x52A0; <strong>&#x4E24;&#x4E2A;</strong> <code>*</code> &#x53EF;&#x4EE5;&#x63A5;&#x6536; <strong>&#x5B57;&#x5178;</strong></li>
</ul>
</li>
<li><p>&#x4E00;&#x822C;&#x5728;&#x7ED9;&#x591A;&#x503C;&#x53C2;&#x6570;&#x547D;&#x540D;&#x65F6;&#xFF0C;<strong>&#x4E60;&#x60EF;</strong>&#x4F7F;&#x7528;&#x4EE5;&#x4E0B;&#x4E24;&#x4E2A;&#x540D;&#x5B57;</p>
<ul>
<li><code>*args</code> &#x2014;&#x2014; &#x5B58;&#x653E; <strong>&#x5143;&#x7EC4;</strong> &#x53C2;&#x6570;&#xFF0C;&#x524D;&#x9762;&#x6709;&#x4E00;&#x4E2A; <code>*</code></li>
<li><code>**kwargs</code> &#x2014;&#x2014; &#x5B58;&#x653E; <strong>&#x5B57;&#x5178;</strong> &#x53C2;&#x6570;&#xFF0C;&#x524D;&#x9762;&#x6709;&#x4E24;&#x4E2A; <code>*</code></li>
</ul>
</li>
<li><p><code>args</code> &#x662F; <code>arguments</code> &#x7684;&#x7F29;&#x5199;&#xFF0C;&#x6709;&#x53D8;&#x91CF;&#x7684;&#x542B;&#x4E49;</p>
</li>
<li><code>kw</code> &#x662F; <code>keyword</code> &#x7684;&#x7F29;&#x5199;&#xFF0C;<code>kwargs</code> &#x53EF;&#x4EE5;&#x8BB0;&#x5FC6; <strong>&#x952E;&#x503C;&#x5BF9;&#x53C2;&#x6570;</strong></li>
</ul>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">demo</span><span class="hljs-params">(num, *args, **kwargs)</span>:</span>

    print(num)
    print(args)
    print(kwargs)


demo(<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>, name=<span class="hljs-string">&quot;&#x5C0F;&#x660E;&quot;</span>, age=<span class="hljs-number">18</span>, gender=<span class="hljs-keyword">True</span>)
</code></pre>
<blockquote>
<p>&#x63D0;&#x793A;&#xFF1A;<strong>&#x591A;&#x503C;&#x53C2;&#x6570;</strong> &#x7684;&#x5E94;&#x7528;&#x4F1A;&#x7ECF;&#x5E38;&#x51FA;&#x73B0;&#x5728;&#x7F51;&#x7EDC;&#x4E0A;&#x4E00;&#x4E9B;&#x5927;&#x725B;&#x5F00;&#x53D1;&#x7684;&#x6846;&#x67B6;&#x4E2D;&#xFF0C;&#x77E5;&#x9053;&#x591A;&#x503C;&#x53C2;&#x6570;&#xFF0C;<strong>&#x6709;&#x5229;&#x4E8E;&#x6211;&#x4EEC;&#x80FD;&#x591F;&#x8BFB;&#x61C2;&#x5927;&#x725B;&#x7684;&#x4EE3;&#x7801;</strong></p>
</blockquote>
<h4 id="&#x591A;&#x503C;&#x53C2;&#x6570;&#x6848;&#x4F8B;-&#x2014;&#x2014;-&#x8BA1;&#x7B97;&#x4EFB;&#x610F;&#x591A;&#x4E2A;&#x6570;&#x5B57;&#x7684;&#x548C;">&#x591A;&#x503C;&#x53C2;&#x6570;&#x6848;&#x4F8B; &#x2014;&#x2014; &#x8BA1;&#x7B97;&#x4EFB;&#x610F;&#x591A;&#x4E2A;&#x6570;&#x5B57;&#x7684;&#x548C;</h4>
<p><strong>&#x9700;&#x6C42;</strong></p>
<ol>
<li>&#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x51FD;&#x6570; <code>sum_numbers</code>&#xFF0C;&#x53EF;&#x4EE5;&#x63A5;&#x6536;&#x7684; <strong>&#x4EFB;&#x610F;&#x591A;&#x4E2A;&#x6574;&#x6570;</strong></li>
<li>&#x529F;&#x80FD;&#x8981;&#x6C42;&#xFF1A;&#x5C06;&#x4F20;&#x9012;&#x7684; <strong>&#x6240;&#x6709;&#x6570;&#x5B57;&#x7D2F;&#x52A0;</strong> &#x5E76;&#x4E14;&#x8FD4;&#x56DE;&#x7D2F;&#x52A0;&#x7ED3;&#x679C;</li>
</ol>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">sum_numbers</span><span class="hljs-params">(*args)</span>:</span>

    num = <span class="hljs-number">0</span>
    <span class="hljs-comment"># &#x904D;&#x5386; args &#x5143;&#x7EC4;&#x987A;&#x5E8F;&#x6C42;&#x548C;</span>
    <span class="hljs-keyword">for</span> n <span class="hljs-keyword">in</span> args:
        num += n

    <span class="hljs-keyword">return</span> num

print(sum_numbers(<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>))
</code></pre>
<h4 id="&#x5143;&#x7EC4;&#x548C;&#x5B57;&#x5178;&#x7684;&#x62C6;&#x5305;&#xFF08;&#x77E5;&#x9053;&#xFF09;">&#x5143;&#x7EC4;&#x548C;&#x5B57;&#x5178;&#x7684;&#x62C6;&#x5305;&#xFF08;&#x77E5;&#x9053;&#xFF09;</h4>
<ul>
<li>&#x5728;&#x8C03;&#x7528;&#x5E26;&#x6709;&#x591A;&#x503C;&#x53C2;&#x6570;&#x7684;&#x51FD;&#x6570;&#x65F6;&#xFF0C;&#x5982;&#x679C;&#x5E0C;&#x671B;&#xFF1A;<ul>
<li>&#x5C06;&#x4E00;&#x4E2A; <strong>&#x5143;&#x7EC4;&#x53D8;&#x91CF;</strong>&#xFF0C;&#x76F4;&#x63A5;&#x4F20;&#x9012;&#x7ED9; <code>args</code></li>
<li>&#x5C06;&#x4E00;&#x4E2A; <strong>&#x5B57;&#x5178;&#x53D8;&#x91CF;</strong>&#xFF0C;&#x76F4;&#x63A5;&#x4F20;&#x9012;&#x7ED9; <code>kwargs</code></li>
</ul>
</li>
<li>&#x5C31;&#x53EF;&#x4EE5;&#x4F7F;&#x7528; <strong>&#x62C6;&#x5305;</strong>&#xFF0C;&#x7B80;&#x5316;&#x53C2;&#x6570;&#x7684;&#x4F20;&#x9012;&#xFF0C;<strong>&#x62C6;&#x5305;</strong> &#x7684;&#x65B9;&#x5F0F;&#x662F;&#xFF1A;<ul>
<li>&#x5728; <strong>&#x5143;&#x7EC4;&#x53D8;&#x91CF;&#x524D;</strong>&#xFF0C;&#x589E;&#x52A0; <strong>&#x4E00;&#x4E2A;</strong> <code>*</code></li>
<li>&#x5728; <strong>&#x5B57;&#x5178;&#x53D8;&#x91CF;&#x524D;</strong>&#xFF0C;&#x589E;&#x52A0; <strong>&#x4E24;&#x4E2A;</strong> <code>*</code></li>
</ul>
</li>
</ul>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">demo</span><span class="hljs-params">(*args, **kwargs)</span>:</span>

    print(args)
    print(kwargs)


<span class="hljs-comment"># &#x9700;&#x8981;&#x5C06;&#x4E00;&#x4E2A;&#x5143;&#x7EC4;&#x53D8;&#x91CF;/&#x5B57;&#x5178;&#x53D8;&#x91CF;&#x4F20;&#x9012;&#x7ED9;&#x51FD;&#x6570;&#x5BF9;&#x5E94;&#x7684;&#x53C2;&#x6570;</span>
gl_nums = (<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>)
gl_xiaoming = {<span class="hljs-string">&quot;name&quot;</span>: <span class="hljs-string">&quot;&#x5C0F;&#x660E;&quot;</span>, <span class="hljs-string">&quot;age&quot;</span>: <span class="hljs-number">18</span>}

<span class="hljs-comment"># &#x4F1A;&#x628A; num_tuple &#x548C; xiaoming &#x4F5C;&#x4E3A;&#x5143;&#x7EC4;&#x4F20;&#x9012;&#x4E2A; args</span>
<span class="hljs-comment"># demo(gl_nums, gl_xiaoming)</span>
demo(*gl_nums, **gl_xiaoming)
</code></pre>
<h2 id="04-&#x51FD;&#x6570;&#x7684;&#x9012;&#x5F52;">04. &#x51FD;&#x6570;&#x7684;&#x9012;&#x5F52;</h2>
<blockquote>
<p>&#x51FD;&#x6570;&#x8C03;&#x7528;&#x81EA;&#x8EAB;&#x7684; <strong>&#x7F16;&#x7A0B;&#x6280;&#x5DE7;</strong> &#x79F0;&#x4E3A;&#x9012;&#x5F52;</p>
</blockquote>
<h3 id="41-&#x9012;&#x5F52;&#x51FD;&#x6570;&#x7684;&#x7279;&#x70B9;">4.1 &#x9012;&#x5F52;&#x51FD;&#x6570;&#x7684;&#x7279;&#x70B9;</h3>
<p><strong>&#x7279;&#x70B9;</strong></p>
<ul>
<li><strong>&#x4E00;&#x4E2A;&#x51FD;&#x6570;</strong> <strong>&#x5185;&#x90E8;</strong> <strong>&#x8C03;&#x7528;&#x81EA;&#x5DF1;</strong><ul>
<li>&#x51FD;&#x6570;&#x5185;&#x90E8;&#x53EF;&#x4EE5;&#x8C03;&#x7528;&#x5176;&#x4ED6;&#x51FD;&#x6570;&#xFF0C;&#x5F53;&#x7136;&#x5728;&#x51FD;&#x6570;&#x5185;&#x90E8;&#x4E5F;&#x53EF;&#x4EE5;&#x8C03;&#x7528;&#x81EA;&#x5DF1;</li>
</ul>
</li>
</ul>
<p><strong>&#x4EE3;&#x7801;&#x7279;&#x70B9;</strong></p>
<ol>
<li>&#x51FD;&#x6570;&#x5185;&#x90E8;&#x7684; <strong>&#x4EE3;&#x7801;</strong> &#x662F;&#x76F8;&#x540C;&#x7684;&#xFF0C;&#x53EA;&#x662F;&#x9488;&#x5BF9; <strong>&#x53C2;&#x6570;</strong> &#x4E0D;&#x540C;&#xFF0C;<strong>&#x5904;&#x7406;&#x7684;&#x7ED3;&#x679C;&#x4E0D;&#x540C;</strong></li>
<li>&#x5F53; <strong>&#x53C2;&#x6570;&#x6EE1;&#x8DB3;&#x4E00;&#x4E2A;&#x6761;&#x4EF6;</strong> &#x65F6;&#xFF0C;&#x51FD;&#x6570;&#x4E0D;&#x518D;&#x6267;&#x884C;<ul>
<li><strong>&#x8FD9;&#x4E2A;&#x975E;&#x5E38;&#x91CD;&#x8981;</strong>&#xFF0C;&#x901A;&#x5E38;&#x88AB;&#x79F0;&#x4E3A;&#x9012;&#x5F52;&#x7684;&#x51FA;&#x53E3;&#xFF0C;&#x5426;&#x5219; <strong>&#x4F1A;&#x51FA;&#x73B0;&#x6B7B;&#x5FAA;&#x73AF;</strong>&#xFF01;</li>
</ul>
</li>
</ol>
<p>&#x793A;&#x4F8B;&#x4EE3;&#x7801;</p>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">sum_numbers</span><span class="hljs-params">(num)</span>:</span>

    print(num)

    <span class="hljs-comment"># &#x9012;&#x5F52;&#x7684;&#x51FA;&#x53E3;&#x5F88;&#x91CD;&#x8981;&#xFF0C;&#x5426;&#x5219;&#x4F1A;&#x51FA;&#x73B0;&#x6B7B;&#x5FAA;&#x73AF;</span>
    <span class="hljs-keyword">if</span> num == <span class="hljs-number">1</span>:
        <span class="hljs-keyword">return</span>

    sum_numbers(num - <span class="hljs-number">1</span>)

sum_numbers(<span class="hljs-number">3</span>)
</code></pre>
<p><img src="https://s2.loli.net/2022/01/11/osTxI1FaSPtYzQj.png" alt="002_&#x9012;&#x5F52;&#x8C03;&#x7528;&#x793A;&#x610F;&#x56FE;I.png"></p>
<h3 id="42-&#x9012;&#x5F52;&#x6848;&#x4F8B;-&#x2014;&#x2014;-&#x8BA1;&#x7B97;&#x6570;&#x5B57;&#x7D2F;&#x52A0;">4.2 &#x9012;&#x5F52;&#x6848;&#x4F8B; &#x2014;&#x2014; &#x8BA1;&#x7B97;&#x6570;&#x5B57;&#x7D2F;&#x52A0;</h3>
<p><strong>&#x9700;&#x6C42;</strong></p>
<ol>
<li>&#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x51FD;&#x6570; <code>sum_numbers</code></li>
<li>&#x80FD;&#x591F;&#x63A5;&#x6536;&#x4E00;&#x4E2A; <code>num</code> &#x7684;&#x6574;&#x6570;&#x53C2;&#x6570;</li>
<li>&#x8BA1;&#x7B97; 1 + 2 + ... num &#x7684;&#x7ED3;&#x679C;</li>
</ol>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">sum_numbers</span><span class="hljs-params">(num)</span>:</span>

    <span class="hljs-keyword">if</span> num == <span class="hljs-number">1</span>:
        <span class="hljs-keyword">return</span> <span class="hljs-number">1</span>

    <span class="hljs-comment"># &#x5047;&#x8BBE; sum_numbers &#x80FD;&#x591F;&#x5B8C;&#x6210; num - 1 &#x7684;&#x7D2F;&#x52A0;</span>
    temp = sum_numbers(num - <span class="hljs-number">1</span>)

    <span class="hljs-comment"># &#x51FD;&#x6570;&#x5185;&#x90E8;&#x7684;&#x6838;&#x5FC3;&#x7B97;&#x6CD5;&#x5C31;&#x662F; &#x4E24;&#x4E2A;&#x6570;&#x5B57;&#x7684;&#x76F8;&#x52A0;</span>
    <span class="hljs-keyword">return</span> num + temp

print(sum_numbers(<span class="hljs-number">2</span>))
</code></pre>
<p><img src="https://s2.loli.net/2022/01/11/MRmJ6NDwcH5A9be.png" alt="002_&#x9012;&#x5F52;&#x8C03;&#x7528;&#x793A;&#x610F;&#x56FE;.png"></p>
<blockquote>
<p>&#x63D0;&#x793A;&#xFF1A;&#x9012;&#x5F52;&#x662F;&#x4E00;&#x4E2A; <strong>&#x7F16;&#x7A0B;&#x6280;&#x5DE7;</strong>&#xFF0C;&#x521D;&#x6B21;&#x63A5;&#x89E6;&#x9012;&#x5F52;&#x4F1A;&#x611F;&#x89C9;&#x6709;&#x4E9B;&#x5403;&#x529B;&#xFF01;&#x5728;&#x5904;&#x7406; <strong>&#x4E0D;&#x786E;&#x5B9A;&#x7684;&#x5FAA;&#x73AF;&#x6761;&#x4EF6;&#x65F6;</strong>&#xFF0C;&#x683C;&#x5916;&#x7684;&#x6709;&#x7528;&#xFF0C;&#x4F8B;&#x5982;&#xFF1A;<strong>&#x904D;&#x5386;&#x6574;&#x4E2A;&#x6587;&#x4EF6;&#x76EE;&#x5F55;&#x7684;&#x7ED3;&#x6784;</strong></p>
</blockquote>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="15.变量进阶（理解）.html" class="navigation navigation-prev " aria-label="Previous page: 15.变量进阶（理解）">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="../课余/编程exe.html" class="navigation navigation-next " aria-label="Next page: 编程exe">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"16.函数进阶","date":"2022-01-19 1:48","tags":"python学习","category":"python学习","level":"7.17","depth":1,"next":{"title":"编程exe","level":"8.1","depth":1,"path":"课余/编程exe.md","ref":"./课余/编程exe.md","articles":[]},"previous":{"title":"15.变量进阶（理解）","level":"7.16","depth":1,"path":"python面对过程学习/15.变量进阶（理解）.md","ref":"./python面对过程学习/15.变量进阶（理解）.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["livereload"],"pluginsConfig":{"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"python面对过程学习/16.函数进阶.md","mtime":"2022-03-15T08:41:19.537Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2022-03-24T13:44:59.630Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

